using UnityEngine;

namespace Naptime.Extensions
{
	public static class FrustumExtension
	{
		public static bool? IsVisibleInCamera(this Transform transform, Camera camera)
		{
			Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
			if (!transform.TryGetComponent<Collider>(out var component))
			{
				return null;
			}
			return GeometryUtility.TestPlanesAABB(planes, component.bounds);
		}
	}
}
